package com.cloud.work.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 该接口为了验证 springboot 最大的请求量测试
 * 是 最大连接数 + 最大等待数 之和
 * 参考参数：
 *  tomcat:
 *     threads:
 *       # 最少线程数
 *       min-spare: 10
 *       # 最多线程数
 *       max: 15
 *     # 最大连接数
 *     max-connections: 30
 *     # 最大等待数
 *     accept-count: 10
 *     参考文章链接：https://zhuanlan.zhihu.com/p/618347306?utm_medium=social&utm_oi=757615486463672320&utm_psn=1626259957506179073&utm_source=wechat_session
 * */
@Api(tags = "springboot最大访问量测试类")
@RestController
@Log4j2
public class RequestTestController {


    @ApiOperation(value = "多个请求最大线程测试")
    @GetMapping("/test")
    public String test1(HttpServletRequest request) throws Exception {
        String threaName = Thread.currentThread().getName();
        log.info("ip:{},线程:{}", request.getRemoteAddr(), threaName);
        Thread.sleep(500);
        return "当前线程："+threaName;
    }


}
